#pragma once
#include <QNetworkAccessManager>
#include <QString>
#include <QUrl>

#define WEB_GET_VERIFICATION_CODE 1          // 获取验证码
#define WEB_GET_VERIFICATION_CONFIRM 2       // 验证验证码
#define WEB_GET_VERIFICATION_MOBILE_STATE 3  // 获取手机状态
#define WEB_GET_SET_PASSWORD 4               // 设置密码
#define WEB_GET_SUBMIT_INFO 5                // 提交信息

struct CFindPasswordMsg {
  CFindPasswordMsg();
  const CFindPasswordMsg& operator=(const CFindPasswordMsg& obj);
  CFindPasswordMsg(const CFindPasswordMsg& obj);
  void Clear();
  int m_nReqID;     // 请求ID;
  int m_nResponse;  // 返回值
  int m_nMobileState;
  bool m_bVerification;       // 是否已验证
  QString m_strAccount;       // 账号
  QString m_strUserID;        // userId
  QString m_strPassWord;      // 密码
  QString m_strMobile;        // 手机号码
  QString m_strVerification;  // 验证码
  QString m_strInititute;     // 机构
  QString m_strDepartment;    // 部门
  QString m_strPosition;      // 职位
  QString m_strTel;           // 固话
  QString m_strQQ;            // QQ
  QString m_strBussiness;     // 业务类型
  QString m_strSeverAdress;   // 服务器地址
};

class CFindPasswordWebReq : public QObject {
  Q_OBJECT
 public:
  CFindPasswordWebReq();
  ~CFindPasswordWebReq();
  void postMessageFunc(const CFindPasswordMsg& msg);
  void reqSumbmitInfo(CFindPasswordMsg& msg, QString strJson);
  void reqSubmitChangePwd(CFindPasswordMsg& msg, QString strJson);
  static int DecodeJson(CFindPasswordMsg& msg, const QString& strJson);
  static bool MakeJson(const CFindPasswordMsg& msg, QString& strJson);
  CFindPasswordMsg* pMsg = nullptr;
 Q_SIGNALS:
  void SendGetMsgComplete();
  void SendPostMsgComplete();
  void SendPutMsgComplete();
 public slots:
  void onGetResponse();
  void onPostResponse();
  void onPutResponse();

 private:
  QNetworkReply* m_reply;
  QNetworkReply* m_postReply;
  QNetworkReply* m_putReply;
  QNetworkAccessManager m_qNetAccessManager;
  QString m_strRespon = "";
};
